import {defineStore} from "pinia";

/**
 * 用户信息pinia实现
 */
export const useUserStore = defineStore("admin", {
        state() {
            return {
                token: '',
                userInfo: {}
            }
        },
        actions: {
            /*
            设置token
             */
            SET_TOKEN(token: string) {
                this.token = token
            },
            /*
            清除token
             */
            CLEAR_TOKEN() {
                this.token = ''
                this.userInfo = {}
            },
            /*
            设置用户信息
             */
            SET_USERINFO(userInfo: any) {
                this.userInfo = userInfo
            },
            /*
            清除用户信息
             */
            CLEAR_USERINFO() {
                this.token = ''
                this.userInfo = {}
            }
        },

    }
)